/// @tags: NodeDiv
#include <cctype>
#include <cstdio>
#include <iostream>
#define lowbit(x) (x & (-x))
using namespace std;

namespace BlueQuantum {

typedef long long ll;

int const N = 2e5 + 5e4 + 5, inf = 1e9;

struct Edge {
  int v, nxt;
} e[N << 1];

int n, L, R, e_cnt;
int rt, wt, totsiz;
int W[N], heads[N], siz[N];
int stk[N], top;
int num[N];
int C0[N], C1[N];
bool vis[N], Cmp[N];
ll ans;

inline void add(int u, int v) { e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt; }

void findrt(int x, int fa) {
  siz[x] = 1;
  int mx = 0;
  for (int i = heads[x], v; i; i = e[i].nxt) {
    if (!vis[v = e[i].v] && v != fa) {
      findrt(v, x);
      siz[x] += siz[v];
      mx = max(mx, siz[v]);
    }
  }
  mx = max(mx, totsiz - siz[x]);
  if (mx < wt) wt = mx, rt = x;
}

void dfs(int x, int fa, bool cmp) {
  if (num[x] <= R) stk[++top] = num[x], Cmp[top] = cmp;
  for (int k = heads[x]; k; k = e[k].nxt) {
    int to = e[k].v;
    if (to == fa || vis[to]) continue;
    num[to] = num[x] + (fa && W[x] > W[fa] && W[x] > W[to]);
    dfs(to, x, fa ? cmp : W[to] < W[x]);
  }
}

inline void modify(int x, bool flag, int val) {
  if (flag)
    for (; x <= n; x += lowbit(x)) C1[x] += val;
  else
    for (; x <= n; x += lowbit(x)) C0[x] += val;
}

inline ll query(int x, bool flag) {
  ll res = 0;
  if (flag)
    for (; x; x -= lowbit(x)) res += C1[x];
  else
    for (; x; x -= lowbit(x)) res += C0[x];
  return res;
}

ll calc(int x, int fa) {
  ll res = 0;
  top = 0;
  num[x] = 0;
  dfs(x, fa, (fa && W[x] < W[fa]));
  for (int i = 1; i <= top; ++i) {
    bool book = Cmp[i];
    if (stk[i] == 0) book ? C1[0]++ : C0[0]++;
    else
      modify(stk[i], book, 1);
  }
  for (int i = 1; i <= top; ++i) {
    bool book = Cmp[i];
    int begin, end;
    if (book == 0) {
      begin = L - stk[i], end = R - stk[i];
      res += query(end, 0) + query(end, 1);
      if (begin > 0) res -= (query(begin - 1, 0) + query(begin - 1, 1));
      if (begin <= 0) res += C0[0] + C1[0];
      if (begin <= stk[i] && stk[i] <= end) res--;
    } else {
      begin = L - stk[i], end = R - stk[i];
      res += query(end, 0);
      if (begin > 0) res -= query(begin - 1, 0);
      if (begin <= 0) res += C0[0];
      begin = L - stk[i] - 1, end = R - stk[i] - 1;
      if (end >= 0) res += query(end, 1);
      if (begin > 0) res -= query(begin - 1, 1);
      if (end >= 0 && begin <= 0) res += C1[0];
      if (begin <= stk[i] && stk[i] <= end) res--;
    }
  }
  for (int i = 1; i <= top; ++i) {
    bool book = Cmp[i];
    if (stk[i] == 0) book ? C1[0]-- : C0[0]--;
    else
      modify(stk[i], book, -1);
    Cmp[i] = 0;
  }
  return res / 2;
}

void solve(int x) {
  ans += calc(x, 0);
  vis[x] = true;
  int tmp = totsiz;
  for (int i = heads[x], v; i; i = e[i].nxt) {
    if (!vis[v = e[i].v]) {
      ans -= calc(v, x);
      rt = 0, wt = N + 100;
      totsiz = (siz[v] > siz[x]) ? tmp - siz[x] : siz[v];
      findrt(v, 0);
      solve(rt);
    }
  }
}

int main() {
  cin >> n >> L >> R;
  for (int i = 1; i <= n; ++i) cin >> W[i];
  for (int i = 1, u, v; i < n; ++i) {
    cin >> u >> v;
    add(u, v), add(v, u);
  }
  totsiz = n;
  wt = N + 100;
  findrt(1, 0);
  solve(rt);
  cout << ans;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("波动路径问题.in", "r", stdin);
  freopen("波动路径问题.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}